home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / ISICOM.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  7KB  |  303 lines

  1. #ifndef _LINUX_ISICOM_H
  2. #define _LINUX_ISICOM_H
  3.  
  4. /*#define        ISICOM_DEBUG*/
  5. /*#define        ISICOM_DEBUG_DTR_RTS*/
  6.  
  7.  
  8. /*
  9.  *    Firmware Loader definitions ...
  10.  */
  11.  
  12. #define        __MultiTech        ('M'<<8)
  13. #define        MIOCTL_LOAD_FIRMWARE    (__MultiTech | 0x01)
  14. #define         MIOCTL_READ_FIRMWARE    (__MultiTech | 0x02)
  15. #define         MIOCTL_XFER_CTRL    (__MultiTech | 0x03)
  16. #define         MIOCTL_RESET_CARD    (__MultiTech | 0x04)
  17.  
  18. #define        DATA_SIZE    16
  19.  
  20. typedef    struct    {
  21.         unsigned short    exec_segment;
  22.         unsigned short    exec_addr;
  23. }    exec_record;
  24.  
  25. typedef    struct    {
  26.         int        board;        /* Board to load */
  27.         unsigned short    addr;
  28.         unsigned short    count;
  29. }    bin_header;
  30.  
  31. typedef    struct    {
  32.         int        board;        /* Board to load */
  33.         unsigned short    addr;
  34.         unsigned short    count;
  35.         unsigned short    segment;
  36.         unsigned char    bin_data[DATA_SIZE];
  37. }    bin_frame;
  38.  
  39. #ifdef __KERNEL__
  40.  
  41. #define        YES    1
  42. #define        NO    0
  43.  
  44. #define        ISILOAD_MISC_MINOR    155    /* /dev/isctl */
  45. #define        ISILOAD_NAME        "ISILoad"
  46.  
  47. /*    
  48.  *  ISICOM Driver definitions ...
  49.  *
  50.  */
  51.  
  52. #define        ISICOM_NAME    "ISICom"
  53.  
  54. /*
  55.  *    These are now officially allocated numbers
  56.  */
  57.  
  58. #define        ISICOM_NMAJOR    112    /* normal  */
  59. #define        ISICOM_CMAJOR    113    /* callout */
  60. #define        ISICOM_MAGIC    (('M' << 8) | 'T')
  61.  
  62. #define        WAKEUP_CHARS    256    /* hard coded for now    */ 
  63. #define        TX_SIZE        254 
  64.  
  65. #define        BOARD_COUNT    4
  66. #define        PORT_COUNT    (BOARD_COUNT*16)
  67.  
  68. #define        SERIAL_TYPE_NORMAL    1
  69. #define        SERIAL_TYPE_CALLOUT    2
  70.  
  71. /*   character sizes  */
  72.  
  73. #define        ISICOM_CS5        0x0000
  74. #define        ISICOM_CS6        0x0001
  75. #define        ISICOM_CS7        0x0002
  76. #define        ISICOM_CS8        0x0003
  77.  
  78. /* stop bits */
  79.  
  80. #define        ISICOM_1SB        0x0000
  81. #define        ISICOM_2SB        0x0004
  82.  
  83. /* parity */
  84.  
  85. #define        ISICOM_NOPAR        0x0000
  86. #define        ISICOM_ODPAR        0x0008
  87. #define        ISICOM_EVPAR        0x0018
  88.  
  89. /* flow control */
  90.  
  91. #define        ISICOM_CTSRTS        0x03
  92. #define        ISICOM_INITIATE_XONXOFF    0x04
  93. #define        ISICOM_RESPOND_XONXOFF    0x08
  94.  
  95. #define InterruptTheCard(base) (outw(0,(base)+0xc)) 
  96. #define ClearInterrupt(base) (inw((base)+0x0a))    
  97.  
  98. #define    BOARD(line)  (((line) >> 4) & 0x3)
  99. #define MIN(a, b) ( (a) < (b) ? (a) : (b) )
  100.  
  101.     /*    isi kill queue bitmap    */
  102.     
  103. #define        ISICOM_KILLTX        0x01
  104. #define        ISICOM_KILLRX        0x02
  105.  
  106.     /* isi_board status bitmap */
  107.     
  108. #define        FIRMWARE_LOADED        0x0001
  109. #define        BOARD_ACTIVE        0x0002
  110.  
  111.      /* isi_port status bitmap  */
  112.  
  113. #define        ISI_CTS            0x1000
  114. #define        ISI_DSR            0x2000
  115. #define        ISI_RI            0x4000
  116. #define        ISI_DCD            0x8000
  117. #define        ISI_DTR            0x0100
  118. #define        ISI_RTS            0x0200
  119.  
  120.  
  121. #define        ISI_TXOK        0x0001 
  122.  
  123. struct    isi_board {
  124.     unsigned short        base;
  125.     unsigned char        irq;
  126.     unsigned char        port_count;
  127.     unsigned short        status;
  128.     unsigned short        port_status; /* each bit represents a single port */
  129.     unsigned short        shift_count;
  130.     struct isi_port        * ports;
  131.     signed char        count;
  132. };
  133.  
  134. struct    isi_port {
  135.     unsigned short        magic;
  136.     unsigned int        flags;
  137.     int            count;
  138.     int            blocked_open;
  139.     int            close_delay;
  140.     unsigned short        channel;
  141.     unsigned short        status;
  142.     unsigned short        closing_wait;
  143.     long             session;
  144.     long            pgrp;
  145.     struct isi_board    * card;
  146.     struct tty_struct     * tty;
  147.     struct wait_queue    * close_wait;
  148.     struct wait_queue    * open_wait;
  149.     struct tq_struct    hangup_tq;
  150.     struct tq_struct    bh_tqueue;
  151.     unsigned char        * xmit_buf;
  152.     int            xmit_head;
  153.     int            xmit_tail;
  154.     int            xmit_cnt;
  155.     struct termios         normal_termios;
  156.     struct termios        callout_termios;
  157. };
  158.  
  159.  
  160. /*
  161.  *  ISI Card specific ops ...
  162.  */
  163.  
  164. extern inline void raise_dtr(struct isi_port * port)
  165. {
  166.     struct isi_board * card = port->card;
  167.     unsigned short base = card->base;
  168.     unsigned char channel = port->channel;
  169.     short wait=300;
  170.     while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
  171.     if (wait <= 0) {
  172.         printk(KERN_WARNING "ISICOM: Card found busy in raise_dtr.\n");
  173.         return;
  174.     }
  175. #ifdef ISICOM_DEBUG_DTR_RTS    
  176.     printk(KERN_DEBUG "ISICOM: raise_dtr.\n");
  177. #endif    
  178.     outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
  179.     outw(0x0504, base);
  180.     InterruptTheCard(base);
  181.     port->status |= ISI_DTR;
  182. }
  183.  
  184. extern inline void drop_dtr(struct isi_port * port)
  185. {    
  186.     struct isi_board * card = port->card;
  187.     unsigned short base = card->base;
  188.     unsigned char channel = port->channel;
  189.     short wait=300;
  190.     while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
  191.     if (wait <= 0) {
  192.         printk(KERN_WARNING "ISICOM: Card found busy in drop_dtr.\n");
  193.         return;
  194.     }
  195. #ifdef ISICOM_DEBUG_DTR_RTS    
  196.     printk(KERN_DEBUG "ISICOM: drop_dtr.\n");
  197. #endif    
  198.     outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
  199.     outw(0x0404, base);
  200.     InterruptTheCard(base);    
  201.     port->status &= ~ISI_DTR;
  202. }
  203. extern inline void raise_rts(struct isi_port * port)
  204. {
  205.     struct isi_board * card = port->card;
  206.     unsigned short base = card->base;
  207.     unsigned char channel = port->channel;
  208.     short wait=300;
  209.     while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
  210.     if (wait <= 0) {
  211.         printk(KERN_WARNING "ISICOM: Card found busy in raise_rts.\n");
  212.         return;
  213.     }
  214. #ifdef ISICOM_DEBUG_DTR_RTS    
  215.     printk(KERN_DEBUG "ISICOM: raise_rts.\n");
  216. #endif    
  217.     outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
  218.     outw(0x0a04, base);
  219.     InterruptTheCard(base);    
  220.     port->status |= ISI_RTS;
  221. }
  222. extern inline void drop_rts(struct isi_port * port)
  223. {
  224.     struct isi_board * card = port->card;
  225.     unsigned short base = card->base;
  226.     unsigned char channel = port->channel;
  227.     short wait=300;
  228.     while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
  229.     if (wait <= 0) {
  230.         printk(KERN_WARNING "ISICOM: Card found busy in drop_rts.\n");
  231.         return;
  232.     }
  233. #ifdef ISICOM_DEBUG_DTR_RTS    
  234.     printk(KERN_DEBUG "ISICOM: drop_rts.\n");
  235. #endif    
  236.     outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
  237.     outw(0x0804, base);
  238.     InterruptTheCard(base);    
  239.     port->status &= ~ISI_RTS;
  240. }
  241. extern inline void raise_dtr_rts(struct isi_port * port)
  242. {
  243.     struct isi_board * card = port->card;
  244.     unsigned short base = card->base;
  245.     unsigned char channel = port->channel;
  246.     short wait=300;
  247.     while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
  248.     if (wait <= 0) {
  249.         printk(KERN_WARNING "ISICOM: Card found busy in raise_dtr_rts.\n");
  250.         return;
  251.     }
  252. #ifdef ISICOM_DEBUG_DTR_RTS    
  253.     printk(KERN_DEBUG "ISICOM: raise_dtr_rts.\n");
  254. #endif    
  255.     outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
  256.     outw(0x0f04, base);
  257.     InterruptTheCard(base);
  258.     port->status |= (ISI_DTR | ISI_RTS);
  259. }
  260. extern inline void drop_dtr_rts(struct isi_port * port)
  261. {
  262.     struct isi_board * card = port->card;
  263.     unsigned short base = card->base;
  264.     unsigned char channel = port->channel;
  265.     short wait=300;
  266.     while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
  267.     if (wait <= 0) {
  268.         printk(KERN_WARNING "ISICOM: Card found busy in drop_dtr_rts.\n");
  269.         return;
  270.     }
  271. #ifdef ISICOM_DEBUG_DTR_RTS    
  272.     printk(KERN_DEBUG "ISICOM: drop_dtr_rts.\n");
  273. #endif    
  274.     outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
  275.     outw(0x0c04, base);
  276.     InterruptTheCard(base);    
  277.     port->status &= ~(ISI_RTS | ISI_DTR);
  278. }
  279.  
  280. extern inline void kill_queue(struct isi_port * port, short queue)
  281. {
  282.     struct isi_board * card = port->card;
  283.     unsigned short base = card->base;
  284.     unsigned char channel = port->channel;
  285.     short wait=300;
  286.     while(((inw(base+0x0e) & 0x01) == 0) && (wait-- > 0));
  287.     if (wait <= 0) {
  288.         printk(KERN_WARNING "ISICOM: Card found busy in kill_queue.\n");
  289.         return;
  290.     }
  291. #ifdef ISICOM_DEBUG    
  292.     printk(KERN_DEBUG "ISICOM: kill_queue 0x%x.\n", queue);
  293. #endif    
  294.     outw(0x8000 | (channel << card->shift_count) | 0x02 , base);
  295.     outw((queue << 8) | 0x06, base);
  296.     InterruptTheCard(base);    
  297. }
  298.  
  299. #endif    /*    __KERNEL__    */
  300.  
  301. #endif    /*    ISICOM_H    */
  302.  
  303.